package com.test.generic;

import com.test.generic.testC.GrandFather;
import com.test.generic.testC.Son;
import com.test.stream.User;

import java.util.*;

/**
 * @Description:
 * @Author: yangzhiwei
 * @Date: 2021/3/5 10:00
 */
public class GenericAdvanced {
    public static void main(String[] args) {
        List<User> list = new ArrayList<>();
        Map<User, User> map = new HashMap<>();
//        Quark<User> quark = new Quark<>();
//        Particle<Long, Double> p = new Particle<>();
        System.out.println(Arrays.toString(list.getClass().getTypeParameters()));
        System.out.println(Arrays.toString(map.getClass().getTypeParameters()));
        System.out.println(Arrays.toString(GrandFather.class.getTypeParameters()));

        List<? extends  GrandFather> grandFathers = new ArrayList<>();
        grandFathers.contains(new Son());
       // 这里对 contains() 和 indexOf() 的调用接受 Apple 对象作为参数，执行没问题。这是否意味着编译器实际上会检查代码，以查看是否有某个特定的方法修改了它的对象？
       // grandFathers.add();
        //grandFathers.add(new Father());
        //[E]
        //[K, V]
        //所以必须做到编译时安全


//        System.out.println(Arrays.toString(quark.getClass().getTypeParameters()));
//        System.out.println(Arrays.toString(p.getClass().getTypeParameters()));

//        System.out.println(users.getClass().getGenericSuperclass());
//        List<? super GrandFather> fathers = new ArrayList<>();
//       // fathers.add(new GrandFather());
//        fathers.add(new Son());
//        fathers.add(new Father());
//        for(GrandFather father : fathers) {
//
//        }



    }
}
